
/*@cc_on
	// check a basic part of the ANTLR JS runtime
	if (!org.antlr.env.ua.ie)
		throw new Error('ANTLR JS target failed to detect JScript!');
@*/

String.prototype.equals = function(otherString) {
	return this.valueOf() === otherString;
}

String.prototype.startsWith = function(otherString) {
	return this.substring(0, otherString.length) == otherString;
}

String.prototype.contains = function(otherString) {
	return this.indexOf(otherString) >= 0;
}

if (!String.prototype.trim) {
	String.whiteSpace = [];
	String.whiteSpace[0x0009] =
	String.whiteSpace[0x000a] =
	String.whiteSpace[0x000b] =
	String.whiteSpace[0x000c] =
	String.whiteSpace[0x000d] =
	String.whiteSpace[0x0020] =
	String.whiteSpace[0x0085] =
	String.whiteSpace[0x00a0] =
	String.whiteSpace[0x1680] =
	String.whiteSpace[0x180e] =
	String.whiteSpace[0x2000] =
	String.whiteSpace[0x2001] =
	String.whiteSpace[0x2002] =
	String.whiteSpace[0x2003] =
	String.whiteSpace[0x2004] =
	String.whiteSpace[0x2005] =
	String.whiteSpace[0x2006] =
	String.whiteSpace[0x2007] =
	String.whiteSpace[0x2008] =
	String.whiteSpace[0x2009] =
	String.whiteSpace[0x200a] =
	String.whiteSpace[0x200b] =
	String.whiteSpace[0x2028] =
	String.whiteSpace[0x2029] =
	String.whiteSpace[0x202f] =
	String.whiteSpace[0x205f] =
	String.whiteSpace[0x3000] =
		true;
	
	String.prototype.trim = function() {
		var str = this.valueOf();
		var len = str.length;
		
		if (len) {
			var whiteSpace = String.whiteSpace, i = 0;
			while (whiteSpace[str.charCodeAt(--len)]);
			if (++len)
				while (whiteSpace[str.charCodeAt(i)]) ++i;
			str = str.substring(i, len);
		}
		
		return str;
	}
}

var ArrayList = Array;

Array.prototype.add = function() {
	if (arguments.length == 2)
		this.splice(arguments[0], 0, arguments[1]);
	else
		this.push(arguments[0]);
}

if (!Array.prototype.indexOf)
	Array.prototype.indexOf = function(item) {
		for (var i = 0; i < this.length; i++)
			if (this[i] == item)
				return i;
		return -1;
	}

Array.prototype.contains = function(item) {
	return this.indexOf(item) > -1;
};

Array.prototype['get'] = function(index) {
	return this[index];
};

Array.prototype.remove = function(index) {
	return this.splice(index, 1)[0];
};

Array.prototype.size = function() {
	return this.length;
};

Array.prototype['set'] = function(index, item) {
	this[index] = item;
};

Array.prototype.peek =
Array.prototype.last = function() {
	return this[this.length-1];
}

Array.prototype.empty = function() {
	return this.length === 0;
}

Array.prototype.addAll = function(arr) {
	this.push.apply(this, arr);
}

Array.prototype.pluck = function(name) {
	var result = [];
	for (var i = 0; i < this.length; i++)
		result.push(this[i][name]);
	return result;
}

var Hashtable = function() {};
Hashtable.prototype['get'] = function(key) {
	return this[key];
}
Hashtable.prototype.put = function(key, value) {
	return this[key] = value;
}
Hashtable.prototype.containsKey = function(key) {
	return key in this;
}
